<template>
    <div class="page">
        <div class="info_top">
            <div class="info_top_img">
                <div class="info_top_img_im" @click="previoust(1)">
                    <img class="img" src="../../static/icon_message_select.png" />
                    <div class="active">基本信息</div>
                </div>
                <div class="info_top_span">
                    <span
                        :class="active<2?'':'active'"
                        class="span"
                        v-for="(itme,index) in 6"
                        :key="index"
                    ></span>
                </div>
                <div class="info_top_img_im" @click="previoust(2)">
                    <img
                        class="img"
                        :src="'../../static/icon_phistory'+(active<2?'':'_select')+'.png'"
                    />
                    <div :class="active<2?'':'active'">孕产史</div>
                </div>
                <div class="info_top_span">
                    <span
                        :class="active<3?'':'active'"
                        class="span"
                        v-for="(itme,index) in 6"
                        :key="index"
                    ></span>
                </div>
                <div class="info_top_img_im" @click="previoust(3)">
                    <img
                        class="img"
                        :src="'../../static/icon_illhistory'+(active<3?'':'_select')+'.png'"
                    />
                    <div :class="active<3?'':'active'">疾病史</div>
                </div>
                <div class="info_top_span">
                    <span
                        :class="active<4?'':'active'"
                        class="span"
                        v-for="(itme,index) in 6"
                        :key="index"
                    ></span>
                </div>
                <div class="info_top_img_im" @click="previoust(4)">
                    <img class="img" :src="'../../static/icon_rate'+(active<4?'':'_select')+'.png'" />
                    <div :class="active<4?'':'active'">高危评级</div>
                </div>
            </div>
        </div>
        <div>
            <information
                :disabled="disabled"
                @neraasdas="neraasdas"
                @previous="previous"
                @getStatus="getStatus"
                :fromList="fromList"
                :array="array"
                :id="id"
                :newlybuild="newlybuild"
                v-if="active==1&&array"
                ref="child1"
            />
            <pregnancyHistory
                @previous="previous"
                :fromList="fromList"
                ref="child2"
                :newlybuild="newlybuild"
                :disabled="disabled"
                v-if="active==2"
            />
            <disease
                @previous="previous"
                :fromList="fromList"
                :disabled="disabled"
                :newlybuild="newlybuild"
                ref="child3"
                v-if="active==3"
            />
            <highRiskRating
                @previous="previous"
                :disabled="disabled"
                ref="child4"
                v-if="active==4"
            />
        </div>
    </div>
</template>
<script>
import disease from "pages/putOnRecord/components/disease.vue";
import information from "pages/putOnRecord/components/information.vue";
import pregnancyHistory from "pages/putOnRecord/components/pregnancyHistory.vue";
import highRiskRating from "pages/putOnRecord/components/highRiskRating.vue";
export default {
    components: {
        information,
        pregnancyHistory,
        disease,
        highRiskRating
    },
    name: "success",
    data() {
        return {
            disabled: false,
            active: 1,
            array: "",
            fromList: [],
            newlybuild:'',
            status:1,
            id:'',
            hospitalId:'',
        };
    },
    onLoad: function(option) {
        

        // console.log(option)
        // console.log(decodeURIComponent(option.hospitalName))
        var _this = this;
        _this.id=option.id
        // _this.disabled=true
        if(option.state&&(option.state==3||option.state==2)){
          _this.disabled=true
        }
        if(option.id==0){
            _this.newlybuild='新建'
            _this.hospitalId=uni.getStorageSync("hospital").id
        }else{
            _this.newlybuild='查看'
            _this.hospitalId=option.hospitalId
             uni.setStorage({
            //存储到本地
            key: "pregnantId",
            data: _this.id
        });
        }
        
        _this.getselectOption();
        _this.getGfieldHospitalListEnable();
    },
    onShow() {

    },
    mounted() {

        // this.getselectOption();
        // this.getGfieldHospitalListEnable();
    },
    methods: {
        neraasdas(){
            this.newlybuild='查看'
        },
        getStatus(status){
          this.status=status
        },
        getAART(array) {
            var _this = this;
            if (array && array.length > 0) {
                for (var i = 0; i < array.length; i++) {
                    if (
                        array[i].fieldType == 4 ||
                        array[i].fieldType == 8 ||
                        array[i].fieldType == 3
                    ) {
                        array[i].valueList = JSON.parse(array[i].valueList);
                    }
                    if (array[i].fieldType == 3||array[i].fieldType == 7) {
                        _this.getAART(array[i].children);
                    }
                }
            }
        },
        getGfieldHospitalListEnable() {
            // 医院档案配置
            var _this = this;
            const data = {
                hospitalId: _this.hospitalId,
                stepId: _this.active
            };
            _this.fromList = [];
            _this.$ajaxs
                .get(
                    "/mobile/v1/gfieldHospital/getGfieldHospitalListEnable",
                    data
                )
                .then(res => {
                    if (res.status == 200) {
                        _this.fromList = res.content;
                        if (_this.active != 1) {
                            for (var i = 0; i < _this.fromList.length; i++) {
                                _this.getAART(_this.fromList[i].children);
                            }
                        }
                    } else {
                        uni.showToast({
                            title: "请检查网络~",
                            icon: "none"
                        });
                    }
                })
                .catch(err => reject(err));
        },
        saveInf() {
            var url = "../index/index"; // 登录跳转页面
            uni.reLaunch({
                url: url
            });
        },
        previous(itme) {
            var _this = this;
            if(itme==_this.active) return
            _this.active = itme;
            _this.getGfieldHospitalListEnable();
        },
        previoust(itme) {
            var _this = this;
            if(itme==_this.active) return;
            if(_this.status<itme) return
            _this.active = itme;
            _this.getGfieldHospitalListEnable();
        },
        getselectOption() {
            // 获取字典列表
            var _this = this;
            _this.$ajaxs
                .get("/mobile/v1/pregnant/getDictionaryAll")
                .then(res => {
                    if (res.status == 200) {
                        var array = res.content;
                        var obj = {};
                        for (var item in array) {
                            if (item == "268380529861341184") {
                                // 证件类型
                                obj.documentType = array[item].sort(
                                    _this.compare("sortId")
                                );
                            }
                            if (item == "319101276443127808") {
                                // 民族类别
                                obj.ethnicA = array[item].sort(
                                    _this.compare("sortId")
                                );
                            }
                            if (item == "319099840787394560") {
                                // 文化程度
                                obj.edulevelA = array[item].sort(
                                    _this.compare("sortId")
                                );
                            }
                            if (item == "319091211069829120") {
                                // 职业
                                obj.jobA = array[item].sort(
                                    _this.compare("sortId")
                                );
                            }
                            if (item == "320629339953836032") {
                                // 户籍类型
                                obj.nationTypeA = array[item].sort(
                                    _this.compare("sortId")
                                );
                            }
                            if (item == "323465182577963008") {
                                // 国籍
                                obj.nationality = array[item].sort(
                                    _this.compare("sortId")
                                );
                            }
                            if (item == "383970291719876608") {
                                // 与本人关系383970291719876608
                                obj.relationship = array[item].sort(
                                    _this.compare("sortId")
                                );
                            }
                            if (item == "319181137572540416") {
                                // 医疗付费方式383970291719876608
                                obj.payWay = array[item].sort(
                                    _this.compare("sortId")
                                );
                            }
                            
                        }
                        _this.array = obj;
                    } else {
                        uni.showToast({
                            title: "请检查网络~",
                            icon: "none"
                        });
                    }
                })
                .catch(err => reject(err));
        },
        //排序方法
        compare(property) {
            return function(a, b) {
                var value1 = a[property];
                var value2 = b[property];
                return value1 - value2;
            };
        }
    }
};
</script>
<style>
.main {
    padding: 0 42upx;
    margin: 0 auto;
}
.info_body {
    background: #fff;
    margin-bottom: 20px;
}
.listItm {
    font-size: 32upx;
    border-bottom: 1px solid #ddd;
}
.listItmTop {
    height: 40upx;
    background: #f8f8f8;
}
.listFlex {
    display: flex;
    position: relative;
    justify-content: space-between;
}
.listCheckT {
    color: #999;
    margin-right: 16upx;
}
.listRight {
    width: 60%;
    height: 100upx;
    line-height: 100upx;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.listLeft36 {
    font-size: 34upx;
    height: 100upx;
    line-height: 100upx;
    width: 40%;
    color: #333;
}
.info_top .pink {
    background-color: #f75193 !important;
    border-color: #f75193 !important;
    color: #ffffff !important;
}
.info_top .listradio_ra {
    background-color: #fa4d93 !important;
    border-color: #fa4d93 !important;
    color: #ffffff !important;
}
.listCheckT .listradio{
    margin-right: 40upx;
    font-size: 30upx;
}
.listCheckT .listradio:last-child{
    margin-right: 0upx;
    
}
.heckbox_s {
    display: inline-block;
    height: 100upx;
    line-height: 100upx;
    min-width: 50%;
}
.listLeft {
    font-size: 30upx;
    height: 100upx;
    line-height: 100upx;
    width: 40%;
    color: #333;
}
.list_tr {
    transition: all 0.1s;
    -webkit-transition: all 0.1s; /* Safari */
}
.inputStyle {
    display: inline-block;
    margin-top: 24upx;
    text-align: right;
    width: 100%;
    color: #999;
}
.hiddenCom {
    visibility: hidden;
}
.btmCon {
    height: 180upx;
    margin-top: 20upx !important;
    background: #fff;
    color: #fa4d93;
}
.btmItm {
    font-size: 20upx;
    color: #fa4d93;
    padding-left: 40upx;
    padding-bottom: 60upx;
}
.weui-cell__ft_in-access {
    padding-right: 13px;
    position: relative;
}
.weui-cell__ft_in-access:after {
    content: " ";
    display: inline-block;
    height: 6px;
    width: 6px;
    border-width: 2px 2px 0 0;
    border-color: #999;
    border-style: solid;
    -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
    transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
    position: relative;
    top: -2px;
    position: absolute;
    top: 50%;
    margin-top: -4px;
    right: 2px;
}
.mustCheck__content {
    position: absolute;
    color: #fa4d93;
    top: 9rpx;
    left: 20upx;
}
</style>
<style lang="scss" scoped>
.page {
    height: 100vh;
    background: #f8f8f8;
    .info_top {
        padding: 18upx 0;
        .info_top_img {
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            padding: 0 120upx;
            text-align: center;
            .active {
                color: #fa4d93;
            }
            .info_top_img_im {
                -webkit-box-flex: 0 0 75upx;
                -ms-flex: 0 0 75upx;
                flex: 0 0 75upx;
                -webkit-box-align: center;
                -ms-flex-align: center;
                align-items: center;
                white-space: nowrap;
                .img {
                    width: 44upx;
                    height: 44upx;
                }
                font-size: 20upx;
            }
            .info_top_span {
                -webkit-box-flex: 1;
                -ms-flex: 1;
                flex: 1;
                -webkit-box-align: center;
                -ms-flex-align: center;
                align-items: center;
                .span {
                    width: 4upx;
                    height: 4upx;
                    margin-right: 8upx;
                    display: inline-block;
                    border-radius: 40%;
                    background: #848484;
                }
                .active {
                    background: #fa4d93;
                }
                span:nth-of-type(6) {
                    margin-right: 0upx;
                }
            }
        }
    }
}
</style>